<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="发展目标" prop="developmentGoalTitle">
        <el-input
          v-model="queryParams.developmentGoalTitle"
          placeholder="请输入发展目标"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="总资产规模" prop="totalAssetScale">
        <el-input
          v-model="queryParams.totalAssetScale"
          placeholder="请输入总资产规模"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总营收规模" prop="totalRevenueScale">
        <el-input
          v-model="queryParams.totalRevenueScale"
          placeholder="请输入总营收规模"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划进入中国前几强" prop="chinaTopRank">
        <el-input
          v-model="queryParams.chinaTopRank"
          placeholder="请输入计划进入中国前几强"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="五大聚焦标题" prop="fiveFocusTitle">
        <el-input
          v-model="queryParams.fiveFocusTitle"
          placeholder="请输入五大聚焦标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题A" prop="focusA">
        <el-input
          v-model="queryParams.focusA"
          placeholder="请输入聚焦标题A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题B" prop="focusB">
        <el-input
          v-model="queryParams.focusB"
          placeholder="请输入聚焦标题B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题C" prop="focusC">
        <el-input
          v-model="queryParams.focusC"
          placeholder="请输入聚焦标题C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题D" prop="focusD">
        <el-input
          v-model="queryParams.focusD"
          placeholder="请输入聚焦标题D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题E" prop="focusE">
        <el-input
          v-model="queryParams.focusE"
          placeholder="请输入聚焦标题E"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="聚焦标题F" prop="focusF">
        <el-input
          v-model="queryParams.focusF"
          placeholder="请输入聚焦标题F"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="践行战略路径标题" prop="strategicPathTitle">
        <el-input
          v-model="queryParams.strategicPathTitle"
          placeholder="请输入践行战略路径标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="践行A" prop="practiceA">
        <el-input
          v-model="queryParams.practiceA"
          placeholder="请输入践行A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="践行B" prop="practiceB">
        <el-input
          v-model="queryParams.practiceB"
          placeholder="请输入践行B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="践行C" prop="practiceC">
        <el-input
          v-model="queryParams.practiceC"
          placeholder="请输入践行C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="践行D" prop="practiceD">
        <el-input
          v-model="queryParams.practiceD"
          placeholder="请输入践行D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dash:outlook:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dash:outlook:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dash:outlook:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dash:outlook:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="outlookList" @selection-change="handleSelectionChange" class="scrollable-table">
      <el-table-column min-width="120" type="selection" width="55" align="center" />
      <el-table-column min-width="120" label="发展目标" align="center" prop="developmentGoalTitle" />
      <el-table-column min-width="120" label="总资产规模" align="center" prop="totalAssetScale" />
      <el-table-column min-width="120" label="总营收规模" align="center" prop="totalRevenueScale" />
      <el-table-column min-width="120" label="计划进入中国前几强" align="center" prop="chinaTopRank" />
      <el-table-column min-width="120" label="五大聚焦" align="center" prop="fiveFocusTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="聚焦A" align="center" prop="focusA" show-overflow-tooltip/>
      <el-table-column min-width="120" label="聚焦B" align="center" prop="focusB" show-overflow-tooltip/>
      <el-table-column min-width="120" label="聚焦C" align="center" prop="focusC" show-overflow-tooltip/>
      <el-table-column min-width="120" label="聚焦D" align="center" prop="focusD" show-overflow-tooltip/>
      <el-table-column min-width="120" label="聚焦E" align="center" prop="focusE" show-overflow-tooltip/>
      <!-- <el-table-column min-width="120" label="聚焦F" align="center" prop="focusF" show-overflow-tooltip/> -->
      <el-table-column min-width="120" label="践行战略路径" align="center" prop="strategicPathTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="实现年份" align="center" prop="achieveYear" show-overflow-tooltip/>
      <el-table-column min-width="120" label="践行A" align="center" prop="practiceA" show-overflow-tooltip/>
      <el-table-column min-width="120" label="践行B" align="center" prop="practiceB" show-overflow-tooltip/>
      <el-table-column min-width="120" label="践行C" align="center" prop="practiceC" show-overflow-tooltip/>
      <el-table-column min-width="120" label="践行D" align="center" prop="practiceD" show-overflow-tooltip/>
      <el-table-column min-width="120" label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['dash:outlook:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dash:outlook:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog :title="title" :visible.sync="open" width="75%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
      <!-- 第一组：发展目标（4个表单项） -->
      <el-divider content-position="left" style="color: #666; font-size: 16px;">发展目标</el-divider>
      <el-row :gutter="20" class="form-row">
        <el-col :span="6">  
             <el-form-item label="目标标题" prop="developmentGoalTitle">
            <el-input v-model="form.developmentGoalTitle" placeholder="请输入发展目标标题" width="220px" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20" class="form-row">
        <el-col :span="6">
        </el-col>
        <el-col :span="6">
          <el-form-item label="总资产规模" prop="totalAssetScale">
            <el-input v-model="form.totalAssetScale" placeholder="请输入总资产规模(亿)" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="总营收规模" prop="totalRevenueScale">
            <el-input v-model="form.totalRevenueScale" placeholder="请输入总营收规模(亿)" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="计划进入前几强" prop="chinaTopRank">
            <el-input v-model="form.chinaTopRank" placeholder="请输入计划进入中国前几强" width="220px" />
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 灰色分隔线 -->
      <el-divider content-position="left" style="color: #666; font-size: 14px;">五大聚焦</el-divider>

      <el-row :gutter="20" class="form-row">
          <el-col :span="6">
            <el-form-item label="五大聚焦标题" prop="fiveFocusTitle">
              <el-input v-model="form.fiveFocusTitle" placeholder="请输入五大聚焦标题" width="220px" />
            </el-form-item>
        </el-col>
      </el-row>
      <!-- 第二组：五大聚焦（4个表单项，剩余2个并入下一行） -->
      <el-row :gutter="20" class="form-row">
       
        <el-col :span="6">
          <el-form-item label="聚焦A" prop="focusA">
            <el-input v-model="form.focusA" placeholder="请输入聚焦标题A" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="聚焦B" prop="focusB">
            <el-input v-model="form.focusB" placeholder="请输入聚焦标题B" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="聚焦C" prop="focusC">
            <el-input v-model="form.focusC" placeholder="请输入聚焦标题C" width="220px" />
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 第二组剩余：五大聚焦（4个表单项，含上组未放完的2个） -->
      <el-row :gutter="20" class="form-row">
        <el-col :span="6">
          <el-form-item label="聚焦D" prop="focusD">
            <el-input v-model="form.focusD" placeholder="请输入聚焦标题D" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="聚焦E" prop="focusE">
            <el-input v-model="form.focusE" placeholder="请输入聚焦标题E" width="220px" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="6">
          <el-form-item label="聚焦标题F" prop="focusF">
            <el-input v-model="form.focusF" placeholder="请输入聚焦标题F" width="220px" />
          </el-form-item>
        </el-col> -->
        <!-- 空列占位，保证每行4列结构统一 -->
        <el-col :span="6"></el-col>
      </el-row>

      <!-- 灰色分隔线 -->
      <el-divider content-position="left" style="color: #666; font-size: 14px;">践行战略</el-divider>

      <!-- 第三组：践行战略路径（4个表单项） -->
       <el-row :gutter="20" class="form-row">
          <el-col :span="6">
            <el-form-item label="践行战略标题" prop="strategicPathTitle">
              <el-input v-model="form.strategicPathTitle" placeholder="请输入践行战略路径标题" width="220px" />
            </el-form-item>
        </el-col>
        <el-col :span="6">
            <el-form-item label="实现年份" prop="achieveYear">
              <el-input v-model="form.achieveYear" placeholder="请输入实现年份" width="220px" />
            </el-form-item>
        </el-col>

       </el-row>
      <el-row :gutter="20" class="form-row">
        <el-col :span="6">
          <el-form-item label="践行A" prop="practiceA">
            <el-input v-model="form.practiceA" placeholder="请输入践行A" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="践行B" prop="practiceB">
            <el-input v-model="form.practiceB" placeholder="请输入践行B" width="220px" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="践行C" prop="practiceC">
            <el-input v-model="form.practiceC" placeholder="请输入践行C" width="220px" />
          </el-form-item>
        </el-col>
         <el-col :span="6">
          <el-form-item label="践行D" prop="practiceD">
            <el-input v-model="form.practiceD" placeholder="请输入践行D" width="220px" />
          </el-form-item>
        </el-col>
      </el-row> 
    
    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
  </div>
</template>

<script>
import { listOutlook, getOutlook, delOutlook, addOutlook, updateOutlook } from "@/api/dash/outlook"

export default {
  name: "Outlook",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 未来展望表格数据
      outlookList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        developmentGoalTitle: null,
        totalAssetScale: null,
        totalRevenueScale: null,
        chinaTopRank: null,
        fiveFocusTitle: null,
        focusA: null,
        focusB: null,
        focusC: null,
        focusD: null,
        focusE: null,
        focusF: null,
        strategicPathTitle: null,
        achieveYear: null,
        practiceA: null,
        practiceB: null,
        practiceC: null,
        practiceD: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        developmentGoalTitle: [
          { required: true, message: "发展目标标题不能为空", trigger: "blur" }
        ],
        fiveFocusTitle: [
          { required: true, message: "五大聚焦标题不能为空", trigger: "blur" }
        ],
        strategicPathTitle: [
          { required: true, message: "践行战略路径标题不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "修改时间不能为空", trigger: "blur" }
        ]
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询未来展望列表 */
    getList() {
      this.loading = true
      listOutlook(this.queryParams).then(response => {
        this.outlookList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        developmentGoalTitle: null,
        totalAssetScale: null,
        totalRevenueScale: null,
        chinaTopRank: null,
        fiveFocusTitle: null,
        focusA: null,
        focusB: null,
        focusC: null,
        focusD: null,
        focusE: null,
        focusF: null,
        strategicPathTitle: null,
        achieveYear: null,
        practiceA: null,
        practiceB: null,
        practiceC: null,
        practiceD: null,
        updateTime: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加未来展望"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getOutlook(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改未来展望"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateOutlook(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addOutlook(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除未来展望编号为"' + ids + '"的数据项？').then(function() {
        return delOutlook(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dash/outlook/export', {
        ...this.queryParams
      }, `outlook_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
<style scoped lang="scss">
.scrollable-table {
  overflow-x: auto; /* 横向溢出时滚动 */
}
/* 优化表格滚动条样式 */
.scrollable-table ::-webkit-scrollbar {
  height: 6px;
}
.scrollable-table ::-webkit-scrollbar-thumb {
  background: #c0c4cc;
  border-radius: 3px;
}
</style>